home *** CD-ROM | disk | FTP | other *** search
- // dice.lib function mega_dice()
- #include <conio.h>
- #include <iostream.h>
- #include <stdlib.h>
- #include <time.h>
-
- int mega_dice(int,int,int,int,int,int);
-
- void main()
- {
- randomize();
-
- mega_dice(0,0,6,5,1,1);
- cout<<"\n";
- }
-
- int mega_dice(int loc,int user,int size,int indice,int seedice,int seesum)
- {
- int dice1,numdice,sum=0;
-
- cout<<"\n[C]omputer controlled ? ";
- if (getche()=='c') //begin if
- goto COMPUTE;
- else //else
- goto USERIN;
- //end if
-
- USERIN:
- cout<<"\nHow many dice ? ";
- cin>>indice;
- for (numdice=1;numdice<=indice;numdice++) {
- cout<<"Enter roll #"<<numdice<<" ";
- cin>>dice1;
- sum=sum+dice1;
- }//end for
- goto END;
-
- COMPUTE:
- cout<<"\n";
- for (numdice=1;numdice<=indice;numdice++) {//begin for
- WAIT: dice1=1+rand()%size; if (user==1 && getche()!=' ') goto WAIT;
- if (seedice==0 && user==0) //begin if
- cout<<" ?";
- else if (seedice==1 && user==0) //else if
- cout<<" "<<dice1;
- else //else
- cout<<dice1;
- //end if
- sum=sum+dice1;
- if (loc==1) //begin if
- cout<<"\n";
- //end if
- }//end for
-
- END:
- if (seesum==0) //begin if
- cout<<" Sum is ?";
- else if (seesum==1) //else if
- cout<<" Sum is "<<sum;
- //end if
-
- return sum;
- }